{% extends "base.html" %}
{% set title = "编辑学生" %}

{% block content %}
    <h2>编辑学生</h2> 
    <form action="{{ url_for('edit_student', id=student.id) }}" method="post">

        <div class="form-group">
            <label for="username">姓名:</label>
            <input type="text" class="form-control" id="username" name="username" value="{{ student.username }}">
        </div>

        <div class="form-group">
            <label for="age">年龄:</label>
            <input type="number" class="form-control" id="age" name="age" value="{{ student.age }}">
        </div>

        <div class="form-group">
            <label for="gender">性别:</label>
            <select class="form-control" id="gender" name="gender" required>
              <option value="男">男</option>
              <option value="女">女</option>
            </select>
        </div>

        <div class="form-group">
            <label for="major_id">专业:</label>
            <select class="form-control" id="major_id" name="major_id">
                <option value="无专业">无专业</option>
                {% for major in majors %}
                <option value="{{ major.id }}" {% if student.major_id == major.id %}selected{% endif %}>{{ major.name }}</option>
                {% endfor %}
            </select>
        </div>
        
        <div class="form-group">
            <label for="password">密码:</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="输入新密码（不修改则留空）">
        </div>
        <br>

        <button type="submit" class="btn btn-primary">修改</button>
        {% if is_admin %}
        <a href="{{ url_for('delete_student', id=student.id) }}" class="btn btn-danger">删除</a>
        {% endif %}
        <a href="{{ url_for('list_students') }}" class="btn btn-secondary">返回学生列表</a>

    </form>

{% endblock %}